/*
 * @Author: jianfanfan 1217572833@qq.com
 * @Date: 2025-04-07 18:02:34
 * @LastEditors: jianfanfan 1217572833@qq.com
 * @LastEditTime: 2025-04-07 20:06:23
 * @FilePath: \chinese-forum\lib\request.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { get, post, put, del } from './api'
import qs from 'qs'

// 通用请求函数
export function request(config) {
    const { url, method, data, params } = config
    switch (method.toLowerCase()) {
        case 'get':
            return get(url, params)
        case 'post':
            return post(url, data)
        case 'put':
            return put(url, data)
        case 'delete':
            return del(url)
        default:
            return post(url, data)
    }
}

//用户注册
export function authRegister(data) {
    return request({
        url: '/auth/register',
        method: 'post',
        data: qs.stringify(data)
    })
}

//用户登录
export function authLogin(data) {
    return request({
        url: '/auth/login',
        method: 'post',
        data: qs.stringify(data)
    })
}